 
import request from "../utils/request";
import {Axios, AxiosResponse} from 'axios'
 
export interface Iuser {
  name:string,
  password:string
}
 interface IResponse{
  code:number
  msg?:string
  token?:string
  user?:{
    name:string
    id:number
    score:number
    user_group:number
    avatar:string
  }

 }
export  function LoginServer(data:Iuser):Promise<AxiosResponse<IResponse>>{  
  return request.post("/api/login",data)
}
export async function LoginApi(data:Iuser):Promise<IResponse>{
  const res = await request.post("/api/login",data)
  if(res.status===200){
    return res.data
  }else{
    throw new Error('Login failed')
  }
}

 